<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
        content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
<title>Sample</title>
</head>
<body>
<script>
//定义当前域
var strDomain = "127.0.0.1";
try{
  // 获取存储区域
  var oStorage = window.localStorage ? window.localStorage : window.globalStorage[strDomain];
  // 察看键visitorCount是否存在
  // 如果存在就读取并加1，增加一次访问统计
  // 如果不存在就意味着第一次访问，我们初始化让它等于1
  if(oStorage.visitorCount){
    oStorage.visitorCount =
               parseInt(oStorage.visitorCount, 10) + 1;
  }else{
    oStorage.visitorCount = 1;
  }
  // 写出访问统计数据
  document.write("欢迎你第<span style='font-weight:bold;'> " +
                     oStorage.visitorCount + " <\/span>访问！");
}catch(err){
  alert(err.message?err.message:err.toString());
}
</script>
</body>
</html>